<template>
  <div>
    <div id="head">
      <!-- 背景图 -->
      <div class="Background">
        <img src="../img/首页/u19.png" alt />
      </div>
      <!-- 头部 -->
      <!-- <div class="head">
        <span>星期一</span>
        <div>
          <span @click="Type"><span class="iconfont icon-fenlei1"></span></span>
          <span @click="Search"
            ><span class="iconfont icon-sousuo"></span
          ></span>
        </div>
      </div>-->
      <Hand @list="Type" @find="Search"></Hand>
      <!-- 干湿分类 -->
      <div class="sort">
        <div class="dry">
          <span>干垃圾</span>
          <span>7:30 - 8:30</span>
        </div>
        <div class="wet">
          <div>
            <span class="night">晚上</span>
            <span>湿垃圾</span>
          </div>
          <span>19:00 - 20:00</span>
        </div>
      </div>
      <!-- 轮播图  懒加载增加性能优化 (懒加载模式下只会加载当前图片和下一张图片) lazy-render 开启懒加载 -->
      <div class="Swipe">
        <Banner :HeiGht="30" :images="Images"></Banner>
      </div>
    </div>
    <!-- 投放日历  上门回收  垃圾识别  每日签到 -->
    <div class="calendar">
      <ul>
        <li @click="Calendar">
          <img src="../img/投放日历等图片/日历.png" alt />
          <span>投放日历</span>
        </li>
        <li @click="Recovery">
          <img src="../img/投放日历等图片/收钱.png" alt />
          <span>上门回收</span>
        </li>
        <li @click="Distinguish">
          <img src="../img/投放日历等图片/拍照.png" alt />
          <span>垃圾识别</span>
        </li>
        <li @click="Everyday">
          <img src="../img/投放日历等图片/签到.png" alt />
          <span>每日签到</span>
        </li>
      </ul>
    </div>
    <!-- 限时兑换 -->
    <div class="Exchange">
      <TimeExchange></TimeExchange>
    </div>
    <!-- 猜你喜欢 -->
    <div class="Live">
      <GuessLike></GuessLike>
    </div>
  </div>
</template>

<script setup>
// 导入轮播图组件
import { reactive, ref } from "vue";
import Banner from "../components/Banner.vue";
import { useRouter, useRoute } from "vue-router";
// 导入猜你喜欢组件
import GuessLike from "../components/Store/GuessLike.vue";
import Commodity from "../components/Store/Commodity.vue";
// 导入头
import Hand from "../components/Hand.vue";
// 导入限时兑换
import TimeExchange from "../components/Store/TimeExchange.vue";
// 导入 pinia
import { useCounterStore } from "../stores/counter.js";
// 引入 字体图标 css
import "../assets/font-icon/iconfont.css";
// 获取签到次数数据
import { useSignInStore } from "../stores/signIn.js";
// 引入轮播图的请求 api
import { slideshow } from "../api/index.js";
import { useListStore } from "../stores/list";
const listStore = useListStore();
const route = useRoute();
// 激活 pinia
const stores = useCounterStore();
const signInStore = useSignInStore();
// 激活 路由
const router = useRouter();
const imagArr = reactive([
  "../img/轮播/QQ图片20221205132151.png",
  "../img/轮播/QQ图片20221205132151.png",
]);
const Images = ref([]);
// 轮播图图片请求数据
slideshow()
  .then((res) => {
    Images.value = res.data.data.slideshows;
  })
  .catch((error) => {
    console.log(error);
  });
// 点击 分类图标
const Type = () => {
  router.push({
    path: "/Classified",
  });
};
// 点击 搜索图标
const Search = () => {
  router.push({
    path: "/Search",
  });
};
// 点击投放日历
const Calendar = () => {
  stores.num = 0;
  router.push({
    path: "/calendar",
  });
};
// 点击每日签到
const Everyday = () => {
  stores.num = 1;
  signInStore.getInfo();
  router.push({
    path: "/everyday",
  });

  // getSignInfo()
  //   .then(res => {
  //     console.log(res.data.data.items);
  //     if (res) {
  //     }
  //   })
  //   .catch(err => {
  //     console.log(err);
  //   });
};
// 点击垃圾识别
const Distinguish = () => {
  router.push({
    path: "/Distinguish",
  });
};
// 点击上门回收
const Recovery = () => {
  router.push({
    path: "/Recovery",
  });
};

function initData() {
  if (route.path === "/Home") {
    listStore.getInfo();
  }
}
initData();
</script>

<style lang="less" scoped>
#head {
  padding-bottom: 230px;
  position: relative;
  // 背景图片
  .Background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 234px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  //   头部样式
  .head {
    span {
      font-family: "微软雅黑 Bold", "微软雅黑 Regular", "微软雅黑";
      font-weight: 700;
      font-size: 20px;
      color: #ffffff;
    }
    width: 100%;
    position: absolute;
    top: 30px;
    display: flex;
    > span {
      position: absolute;
      left: 20px;
    }
    div {
      position: absolute;
      right: 20px;
    }
    div span:nth-of-type(1) {
      margin-right: 10px;
    }
  }
  // 干湿分类样式
  .sort {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: absolute;
    top: 70px;
    left: 20px;
    height: 74px;
    width: 90%;
    border-radius: 5px;
    background-color: rgba(133, 227, 237, 0.8);
    span {
      font-family: "微软雅黑";
      font-weight: 400;
      font-style: normal;
      color: #ffffff;
      text-align: left;
    }
    .dry {
      display: flex;
      flex-direction: column;
    }
    .wet {
      display: flex;
      flex-direction: column;
      .night {
        padding: 0 3px;
        border-radius: 5px;
        background-color: rgba(255, 0, 0, 0.7);
      }
    }
  }
  // 轮播图样式
  .Swipe {
    position: absolute;
    top: 150px;
    left: 20px;
    height: 120px;
  }
}

// 猜你喜欢的样式
.Live {
  margin-left: 15px;
}

// <!-- 投放日历  上门回收  垃圾识别  每日签到  样式-->
.calendar {
  ul {
    display: flex;
    justify-content: space-around;
    align-items: center;

    li {
      display: flex;
      flex-direction: column;
      align-items: center;
      span {
        font-family: "微软雅黑";
        font-weight: 400;
        font-size: 12px;
      }
      img {
        margin-bottom: 1vw;
        display: block;
        width: 8vw;
        height: 8vw;
      }
    }
  }
}
.Exchange {
  margin-left: 12px;
}
</style>
